package com.mine.education.course.controller;

import java.util.Arrays;
import java.util.Map;

import com.mine.education.common.utils.PageUtils;
import com.mine.education.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.mine.education.course.entity.DescriptionEntity;
import com.mine.education.course.service.DescriptionService;



/**
 * 课程描述表
 *
 * @author xiaolin
 * @email xiaolin@gmail.com
 * @date 2020-10-18 15:58:35
 */
@RestController
@RequestMapping("course/description")
public class DescriptionController {
    @Autowired
    private DescriptionService descriptionService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("course:description:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = descriptionService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("course:description:info")
    public R info(@PathVariable("id") Long id){
		DescriptionEntity description = descriptionService.getById(id);

        return R.ok().put("description", description);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("course:description:save")
    public R save(@RequestBody DescriptionEntity description){
		descriptionService.save(description);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("course:description:update")
    public R update(@RequestBody DescriptionEntity description){
		descriptionService.updateById(description);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("course:description:delete")
    public R delete(@RequestBody Long[] ids){
		descriptionService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
